<html  ng-app="app">
<head>
    <meta charset="utf-8" >
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <title>房间战绩</title>
    <script type="text/javascript" src="<?php echo $image_url;?>files/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="<?php echo $image_url;?>files/js/fastclick.js"></script>
    <script type="text/javascript" src="<?php echo $image_url;?>files/js/angular.min.js"></script>
    <script type="text/javascript">
        var gameType = null;

        $(function () {
            var roomId = "<?php echo $roomId;?>";
            var gameType = "<?php echo $gameType;?>";
            FastClick.attach(document.body);
        });
        var baseUrl ="<?php echo $base_url;?>";
        var app = angular.module('app',[])
        app.controller("myCtrl", function($scope,$http) {
            $scope.width = window.innerWidth;
            $scope.height = window.innerHeight;
            $scope.baseURL = '<?php echo $base_url;?>';
            $scope.gameType = '<?php echo $gameType;?>';
            $scope.roomId = '<?php echo $roomId;?>';
            $scope.roomNumber = '<?php echo $roomNumber;?>';

            $(".main").show();
            $("#loading").hide();

            $scope.getScore = function () {
                $http({
                    url:$scope.baseURL + 'ay/roI',
                    method:'POST',
                    header:{'Content-Type':'application/x-www-form-urlencoded'},
                    data:{
                        'gameType':$scope.gameType,
                        'roomId' : $scope.roomId
                    }})
                    .success(function (data, header, config, status) {
                        var json = eval(data);
                        $.each(json.data,function(i,e){
                            gameType = e.game_type;
                            var gameResult=eval("("+e.game_result+")");
                            e.game_result =gameResult ;
                            var bm = gameResult.gData.bmult;
                            var bid = gameResult.gData.bid;
                            $.each(e.game_result.pAry,function(i,e){
                                //var cs = e.c.split(",");
                                var cs = e.c==null||e.c==undefined?[]:e.c.split(",");
                                e.c = cs;
                                if(e.m==0)e.m=bm;
                                e.p = e.p == bid ;
                            });

                        });
                        var htm = $("#j_renderJuTemp").render(json);
                        $("#j_detailDiv").html(htm);
                    }).error( function (data, header, config, status) {
                    console.log(data);
                });
            }

            $scope.getScore();

        })

        function formatShowTime(time) {
            var newDate = new Date();
            newDate.setTime(time * 1000);
            var year = newDate.getFullYear();
            var month = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1);
            var day = newDate.getDate() < 10 ? '0' + newDate.getDate() : newDate.getDate() ;
            var hour = newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours() ;
            var min = newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes();

            var showTime = year + '-' + month + '-' + day + '        ' + hour +':' + min ;
            return showTime;
        }

        function createRank()
        {
            var roomNumber = "<?php echo $roomNumber;?>";
            var str = "";
            switch (parseInt(gameType)){
                case 59: str = "nb"; break;
                case 58: str = "b8b"; break;
                case 56: str = "b6b"; break;
                case 52: str = "mb"; break;
                case 53: str = "laib"; break;
                case 55: str = "b"; break;

                case 29: str = "z9"; break;
                case 30: str = "z12"; break;
                case 26: str = "yf"; break;
                case 24: str = "mpZjh";break;
                case 25: str = "xpjh"; break;

                case 2: str = "l"; break;
                case 6: str = "ma"; break;
                case 8: str = "eba"; break;
                case 3: str = "sg"; break;
                case 19: str = "pj"; break;
                case 22: str = "sg9"; break;
                case 20: str = "dcx"; break;
                case 21: str = "yxx"; break;

                default: str = "b"; break;
            };
            // switch (parseInt(gameType)){
            //     case 29:
            //         str = "z9";
            //         break;
            //     case 26:
            //         str = "yf";
            //         break;
            //     case 58:
            //         str = "b8b";
            //         break;
            //     case 55:
            //         str = "b";
            //         break;
            //     case 59:
            //         str = "nb";
            //         break;
            //     case 56:
            //         str = "b6b";
            //         break;
            //     case 52:
            //         str = "mb";
            //         break;
            //     case 53:
            //         str = "laib";
            //         break;
            //     default:
            //         str = "b";
            //         break;
            // };
            window.location.href = baseUrl + "f/"+str+"?i="+roomNumber+"_";
        }
    </script>
<style>
    body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{
        margin:0px; padding:0px;
    }
    img{border:none}
    li,ol,ul {
        list-style: none;
    }
    h1,h2,h3,h4,h5,h6 {
        font-style: normal; font-size: 12px; font-weight: normal;
    }
    .fl{float:left;}
    .w{width:100%;}
    .pt15{padding-top:15px;}
    .ptb10{padding-top:10px;padding-bottom:10px;}
    .pt10{padding-top:10px;}
    .pl10{padding-left:10px;}
    .h30{height:30px;}
    .lh30{line-height:30px;}
    .h20{height:20px;}
    .lh20{line-height:20px;}
    .fs18{font-size:18px;}
    .fs16{font-size:16px;}
    .fs14{font-size:14px;}
    .bgf{background:#fff;}
    .bgf5{background:#f5f5f5;}
    .bline{border-bottom:#ccc solid 1px;}
    .tac{text-align:center}
    .c4{color:#444;}
    .c6{color:#666;}
    .cB{color:#6e80a6;}
    .c7{color:#777;}
    .c9{color:#999;}
    .pr5{padding-right:5px;}
    .fr{float:right;}
    .fs13{font-size:13px;}
    .plr1{padding-left:1px; padding-right:1px;}
    .hidd{overflow:hidden;}
    .zhuang{
        position:absolute;z-index:99;margin-top:-22px;width:20px;height:20px;text-align:center;line-height:20px;border:#ff2d5e solid 1px;border-radius:30px;
        font-size:14px; color:#ff2d5e;
    }
</style>
</head>
<body ng-controller="myCtrl" class="bgf5">
<div class="fl" style="margin:10px 1%;width:98%" onclick="createRank()">
    <div class="fl w tac" style="height: 7vh;line-height:7vh;background:#f14b19;color:#fff;border-radius:3px;">生成积分榜</div>
</div>
<div class="fl w" id="j_detailDiv"></div>




<script type="text/x-jsrender" id="j_renderJuTemp">
{{for data}}
<div class="w fl pt15">
    <span class="pl10 h20 lh20 fs16 c4">{{:game_result.gData.gnum}}/{{:game_result.gData.tnum}}局</span>
</div>
{{if game_type == 52 || game_type == 53 || game_type == 55 || game_type == 56 || game_type == 58 ||  game_type == 59 }}
<div class="fl w bgf">
    <div class="w bline ptb10 fl">
	    <table width=98% align=center cellspacing=0 cellpadding=0 border=0>
		    <tr>
				<td width=32%>
                    <span class="w fl tac fs14 c6">玩家名称</span>
				</td>
				<td width=45%>
				    <span class="w fl tac fs14 c6">牌型</span>
				</td>
				<td width=10%>
					<span class="w fl tac fs14 c6">倍数</span>
			    </td>
				<td width=13%>
					<span class="w fl tac fs14 c6">得分</span>
			    </td>
			</tr>
		</table>
	</div>
    <ul>
	    {{for game_result.pAry}}
	    <li>
		    <div class="w bline ptb10 fl">
	        <table width=98% align=center cellspacing=0 cellpadding=0 border=0>
		    <tr>
				<td width=32%>
				    {{if p}}
				    <span class="zhuang">庄</span>
					{{/if}}
                    <span class="w fl tac fs14 cB hidd h20 lh20">{{:n}}</span>
				</td>
				<td width=6% align=center>
				    <span style="width:12px;" class="pr5 fr fs13 c6 plr1">{{setPoint:ct cp m}}</span>
				</td>
				<td width=39%>
					<div class="fl w tac">
						{{for c}}
						{{if #index==0}}
						<span class="fl hidd"><img src="<?php echo $image_url;?>/files/images/pai/{{setPaiImage:#data}}.png" width=39 height=50></span>
						{{else}}
						<span class="fl hidd" style="margin-left:-20px;"><img src="<?php echo $image_url;?>/files/images/pai/{{setPaiImage:#data}}.png" width=39 height=50></span>
						{{/if}}
						{{/for}}
				    </div>
				</td>
				<td width=10%>
					<span class="w fl tac fs14 c6">{{:m}}</span>
			    </td>
				<td width=13%>
					<span class="w fl tac fs14 c6">{{:s}}</span>
			    </td>
			</tr>
		    </table>
	        </div>
		</li>
		{{/for}}
	</ul>
</div>
{{else}}
<div class="fl w bgf">
    <div class="w bline ptb10 fl">
	    <table width=98% align=center cellspacing=0 cellpadding=0 border=0>
		    <tr>
				<td width=32%>
                    <span class="w fl tac fs14 c6">玩家名称</span>
				</td>
				<td width=15%>
					<span class="w fl tac fs14 c6">牌型</span>
			    </td>
				<td width=40%>
				    <span class="w fl tac fs14 c6">牌</span>
				</td>
				<td width=13%>
					<span class="w fl tac fs14 c6">下注</span>
			    </td>
			</tr>
		</table>
	</div>
    <ul>
	    {{for game_result.pAry}}
	    <li>
		    <div class="w bline ptb10 fl">
	        <table width=98% align=center cellspacing=0 cellpadding=0 border=0>
		    <tr>
				<td width=32%>
				    {{if isZhuang==1}}
				    <span class="zhuang">庄</span>
					{{/if}}
                    <span class="w fl tac fs14 cB hidd h20 lh20">{{:n}}</span>
				</td>
				<td width=15% align=center>
				    <span class="w fl fs13 c6 tac">{{setZJHPoint:ct}}</span>
				</td>
				<td width=40% align=center>
						{{for c}}
						{{if #index==0}}
						<span class=" hidd"><img src="<?php echo $image_url;?>/files/images/pai/{{setPaiImage:#data}}.png" height=50></span>
						{{else}}
						<span style="margin-left:-10px;" class=" hidd"><img src="<?php echo $image_url;?>/files/images/pai/{{setPaiImage:#data}}.png" height=50></span>
						{{/if}}
						{{/for}}
				</td>
				<td width=13%>
					<span class="w fl tac fs14 c6">{{:s}}</span>
			    </td>
			</tr>
		    </table>
	        </div>
		</li>
		{{/for}}
	</ul>
</div>
{{/if}}
{{/for}}
</script>

</body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsrender/0.9.90/jsrender.js"></script>
<script type="text/javascript">
    $.views.converters({
        setPoint:function(p,cp,m) {
            var s = "";
            switch (parseInt(p)) {
                    case 7:
                        s = "五小牛";
                        break;
                    case 6:
                        s = "炸弹牛";
                        break;
                    case 5:
                        s = "五花牛";
                        break;
                    case 4:
                        s = "牛牛";
                        break;
                    case 3:
                        ;
                    case 2:
                        s = "牛" + cp;
                        break;
                    case 1:s=m==-1?"未参与":"无牛";
                        break;
                    default :
                        s = "";
                        break;
            }
            return s ;
        },
        setZJHPoint:function(p){
            var s = "" ;
                switch(parseInt(p)){
                    case 6: s = "三条"; break;
                    case 5: s = "同花顺"; break;
                    case 4: s = "同花"; break;
                    case 3: s = "顺子"; break;
                    case 2: s = "对子"; break;
                    case 1: s = "高牌"; break;
                    default : s = ""; break;
                }
            return s ;
        },
        setPaiImage:function(p){
            if(p==null||p=="null"||p==""){
                return "0" ;
            }else{
                return p ;
            }
        }
    });
</script>
</html>
